#ifndef DATASERVER_INIT_H
#define DATASERVER_INIT_H

#define COL_CLUSTER                         "col"

#include <pthread.h>
#include "connpool.h"

typedef struct storages
{
    char    name[1024];
    char    rowkey[1024];
    char    store[32];
    char    ctime[128];
    char    desc[10240];
    char    address[128];
    char    fields[1024];
    char    hrkey[1204];
    struct  storages *next;
}Storages;

typedef struct indexs
{
    char    storage[1024];
    char    rowkey[1024];
    char    prefix[1024];
    char    index[1024];
    char    ctime[128];
    char    hrkey[1024];
    char    memlink_addr[1024];
    struct  indexs *next;
}Indexs;

typedef struct _runtime
{
    ConnPool *cp;
    Storages  *st;
    Indexs   *id;
	pthread_mutex_t st_m;
	pthread_mutex_t id_m;
	Config *conf;
}Runtime;

extern Runtime *g_rt;

int dataserver_init(char *conf);
int storages_add(const char *name, const char *rowkey, const char *store, const char *ctime, const char *desc, const char *address, const char *fields);
int index_add(const char *storage, const char *rowkey, const char *prefix, const char *index, const char *ctime, const char *memlink_addr, const char *hrkey);
int find_index_item(const char *item, Indexs **find, Indexs **pre);
int index_print();

#endif
